package com.msb.userclient.client;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author DreamAndLove
 * @date 2024/09/06 15:05
 * @description
 */
@Component
public class UserClientFallbackFactory implements FallbackFactory<UserClient> {
    @Override
    public UserClient create(Throwable throwable) {

        return new UserClient() {
            @Override
            public JSONObject getUser() {
                return null;
            }

            @Override
            public String timeoutTest() {
                String jsonString = JSON.toJSONString(throwable);
                return "fall back method--error message is: "+ jsonString;
            }

            @Override
            public JSONObject getUserInfo(String name) {
                return null;
            }
        };
    }
}
